/**
 * 
 */
package com.bagtrack.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;


/**
 * @author Brian Boyle
 * Nov 13, 2011
 *
 */
@Entity
@Table(name = "AIRCRAFT_TYPE")
public class AircraftType {

    private Long id;
    private String aircraftType;
    private double averageUnloadTime;
    private List<Flight> flights;


    /**
     * @param aircraftType
     * @param averageUnloadTime
     */
    public AircraftType(String aircraftType, double averageUnloadTime) {
        this.aircraftType = aircraftType;
        this.averageUnloadTime = averageUnloadTime;
    }

    /**
     * Default Constructor
     */
    public AircraftType() {

    }

    /**
     * @return the id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID")
    public Long getId() {
        return id;
    }


    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }


    /**
     * @return the aircraftType
     */
    @Column(name = "TYPE")
    public String getAircraftType() {
        return aircraftType;
    }


    /**
     * @param aircraftType the aircraftType to set
     */
    public void setAircraftType(String aircraftType) {
        this.aircraftType = aircraftType;
    }


    /**
     * @return the averageUnloadTime
     */
    @Column(name = "AVG_UNLOAD_TIME")
    public double getAverageUnloadTime() {
        return averageUnloadTime;
    }


    /**
     * @param averageUnloadTime the averageUnloadTime to set
     */
    public void setAverageUnloadTime(double averageUnloadTime) {
        this.averageUnloadTime = averageUnloadTime;
    }

    /**
     * @return the flights
     */
    @OneToMany(mappedBy = "aircraftType", fetch = FetchType.LAZY)
    @JsonIgnore
    public List<Flight> getFlights() {
        return flights;
    }

    public void setFlights(List<Flight> flights) {
        this.flights = flights;
    }


    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "AircraftType [id=" + id + ", aircraftType=" + aircraftType + ", averageUnloadTime=" + averageUnloadTime + "]";
    }
}
